package com.example.recyclerview.viewHolder

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.example.recyclerview.*
import com.example.remindme.R


class ViewAdapter(private val dataList: List<UsingData>):RecyclerView.Adapter<RecyclerView.ViewHolder> ()
{

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        val inflater=LayoutInflater.from(parent.context)
        val blockViewHolder= ViewHolderBlock(
            inflater.inflate(
                R.layout.app_using_msg, parent,
                false
            )
        // 要在这里注册vieholder 要访问的元素的文件
        )
       return blockViewHolder
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        val item=dataList[position]
        if(holder is ViewHolderBlock)
            holder.bind(item)

    }

    override fun getItemCount(): Int {
        return dataList.size
    }

}